package yunxiangchuan

import (
	
	"github.com/flipped-aurora/gin-vue-admin/server/global"
    "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
    "github.com/flipped-aurora/gin-vue-admin/server/model/yunxiangchuan"
    yunxiangchuanReq "github.com/flipped-aurora/gin-vue-admin/server/model/yunxiangchuan/request"
    "github.com/gin-gonic/gin"
    "go.uber.org/zap"
)

type AlbumDecorationsApi struct {}



// CreateAlbumDecorations 创建相册装饰管理
// @Tags AlbumDecorations
// @Summary 创建相册装饰管理
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body yunxiangchuan.AlbumDecorations true "创建相册装饰管理"
// @Success 200 {object} response.Response{msg=string} "创建成功"
// @Router /albumDecorations/createAlbumDecorations [post]
func (albumDecorationsApi *AlbumDecorationsApi) CreateAlbumDecorations(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	var albumDecorations yunxiangchuan.AlbumDecorations
	err := c.ShouldBindJSON(&albumDecorations)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = albumDecorationsService.CreateAlbumDecorations(ctx,&albumDecorations)
	if err != nil {
        global.GVA_LOG.Error("创建失败!", zap.Error(err))
		response.FailWithMessage("创建失败:" + err.Error(), c)
		return
	}
    response.OkWithMessage("创建成功", c)
}

// DeleteAlbumDecorations 删除相册装饰管理
// @Tags AlbumDecorations
// @Summary 删除相册装饰管理
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body yunxiangchuan.AlbumDecorations true "删除相册装饰管理"
// @Success 200 {object} response.Response{msg=string} "删除成功"
// @Router /albumDecorations/deleteAlbumDecorations [delete]
func (albumDecorationsApi *AlbumDecorationsApi) DeleteAlbumDecorations(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	id := c.Query("id")
	err := albumDecorationsService.DeleteAlbumDecorations(ctx,id)
	if err != nil {
        global.GVA_LOG.Error("删除失败!", zap.Error(err))
		response.FailWithMessage("删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("删除成功", c)
}

// DeleteAlbumDecorationsByIds 批量删除相册装饰管理
// @Tags AlbumDecorations
// @Summary 批量删除相册装饰管理
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{msg=string} "批量删除成功"
// @Router /albumDecorations/deleteAlbumDecorationsByIds [delete]
func (albumDecorationsApi *AlbumDecorationsApi) DeleteAlbumDecorationsByIds(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	ids := c.QueryArray("ids[]")
	err := albumDecorationsService.DeleteAlbumDecorationsByIds(ctx,ids)
	if err != nil {
        global.GVA_LOG.Error("批量删除失败!", zap.Error(err))
		response.FailWithMessage("批量删除失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("批量删除成功", c)
}

// UpdateAlbumDecorations 更新相册装饰管理
// @Tags AlbumDecorations
// @Summary 更新相册装饰管理
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data body yunxiangchuan.AlbumDecorations true "更新相册装饰管理"
// @Success 200 {object} response.Response{msg=string} "更新成功"
// @Router /albumDecorations/updateAlbumDecorations [put]
func (albumDecorationsApi *AlbumDecorationsApi) UpdateAlbumDecorations(c *gin.Context) {
    // 从ctx获取标准context进行业务行为
    ctx := c.Request.Context()

	var albumDecorations yunxiangchuan.AlbumDecorations
	err := c.ShouldBindJSON(&albumDecorations)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	err = albumDecorationsService.UpdateAlbumDecorations(ctx,albumDecorations)
	if err != nil {
        global.GVA_LOG.Error("更新失败!", zap.Error(err))
		response.FailWithMessage("更新失败:" + err.Error(), c)
		return
	}
	response.OkWithMessage("更新成功", c)
}

// FindAlbumDecorations 用id查询相册装饰管理
// @Tags AlbumDecorations
// @Summary 用id查询相册装饰管理
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param id query int true "用id查询相册装饰管理"
// @Success 200 {object} response.Response{data=yunxiangchuan.AlbumDecorations,msg=string} "查询成功"
// @Router /albumDecorations/findAlbumDecorations [get]
func (albumDecorationsApi *AlbumDecorationsApi) FindAlbumDecorations(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	id := c.Query("id")
	realbumDecorations, err := albumDecorationsService.GetAlbumDecorations(ctx,id)
	if err != nil {
        global.GVA_LOG.Error("查询失败!", zap.Error(err))
		response.FailWithMessage("查询失败:" + err.Error(), c)
		return
	}
	response.OkWithData(realbumDecorations, c)
}
// GetAlbumDecorationsList 分页获取相册装饰管理列表
// @Tags AlbumDecorations
// @Summary 分页获取相册装饰管理列表
// @Security ApiKeyAuth
// @Accept application/json
// @Produce application/json
// @Param data query yunxiangchuanReq.AlbumDecorationsSearch true "分页获取相册装饰管理列表"
// @Success 200 {object} response.Response{data=response.PageResult,msg=string} "获取成功"
// @Router /albumDecorations/getAlbumDecorationsList [get]
func (albumDecorationsApi *AlbumDecorationsApi) GetAlbumDecorationsList(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

	var pageInfo yunxiangchuanReq.AlbumDecorationsSearch
	err := c.ShouldBindQuery(&pageInfo)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	list, total, err := albumDecorationsService.GetAlbumDecorationsInfoList(ctx,pageInfo)
	if err != nil {
	    global.GVA_LOG.Error("获取失败!", zap.Error(err))
        response.FailWithMessage("获取失败:" + err.Error(), c)
        return
    }
    response.OkWithDetailed(response.PageResult{
        List:     list,
        Total:    total,
        Page:     pageInfo.Page,
        PageSize: pageInfo.PageSize,
    }, "获取成功", c)
}

// GetAlbumDecorationsPublic 不需要鉴权的相册装饰管理接口
// @Tags AlbumDecorations
// @Summary 不需要鉴权的相册装饰管理接口
// @Accept application/json
// @Produce application/json
// @Success 200 {object} response.Response{data=object,msg=string} "获取成功"
// @Router /albumDecorations/getAlbumDecorationsPublic [get]
func (albumDecorationsApi *AlbumDecorationsApi) GetAlbumDecorationsPublic(c *gin.Context) {
    // 创建业务用Context
    ctx := c.Request.Context()

    // 此接口不需要鉴权
    // 示例为返回了一个固定的消息接口，一般本接口用于C端服务，需要自己实现业务逻辑
    albumDecorationsService.GetAlbumDecorationsPublic(ctx)
    response.OkWithDetailed(gin.H{
       "info": "不需要鉴权的相册装饰管理接口信息",
    }, "获取成功", c)
}
